<template>
    <div>


        <van-cell-group v-if="bandShow" align="left" style="margin-top: 1rem;margin-bottom: 2rem">
            <van-field v-model="fillInId" label="电脑id" placeholder="请输入电脑id"/>
        </van-cell-group>
        <van-button v-if="bandShow" style="margin-bottom: 2rem;margin-top: 2rem" type="primary" @click="fillIn()" block>手动绑定电脑
        </van-button>
        <van-button v-if="bandShow" style="margin-bottom: 2rem;margin-top: 2rem" type="primary" @click="ScanPC(scanType.pcScan)" block>扫码绑定电脑
        </van-button>
        <div  v-if="!bandShow">
            <van-button style="margin-bottom: 2rem;margin-top: 2rem" type="primary" @click="ScanPC(scanType.ybScan)" block>扫码
            </van-button>
            <van-cell-group align="left" style="margin-top: 1rem;margin-bottom: 2rem">
                <van-cell title="用户ID" v-model="PCUserId" size="large"/>
                <van-cell title="扫码结果" v-model="message" size="large"/>
            </van-cell-group>
            <van-button style="margin-bottom: 2rem;margin-top: 2rem" type="primary" @click="send()" block>发送扫码结果给电脑
            </van-button>
            <van-button style="margin-bottom: 2rem;margin-top: 2rem" type="primary" @click="resetPcId()" block>重新绑定电脑id
            </van-button>
        </div>


    </div>
</template>

<script>


import {wxScan} from  "@/mixins/WxScan.js"
    export default {
        name: "IphonScan",
        mixins:[wxScan],
        data() {
            return {
                scanType:{
                    pcScan:1,
                    ybScan:2
                },
                res: null,
                serverTimeoutObj: null,
                PCUserId: '',
                code: '',
                openid: window.localStorage.getItem('openid'),
                ws: null,
                message:'',
                bandShow:true,
                fillInId:null,
                timeoutObj: null,
                timeout: 500000,
            }
        },
        mounted() {
           // this.WXScanCode();
            this. connect();
        },

        methods: {
            fillIn(){
                this.PCUserId=this.fillInId;
                this.bandShow=false;
            },
            resetPcId(){
                this.PCUserId='';
                this.bandShow=true;
            }
        }
    }
</script>

<style scoped>

</style>